package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.HousingTrust;
import com.ruoyi.system.mapper.HousingTrustMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HousingOrderMapper;
import com.ruoyi.system.domain.HousingOrder;
import com.ruoyi.system.service.IHousingOrderService;

/**
 * 交易管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Service
public class HousingOrderServiceImpl implements IHousingOrderService 
{
    @Autowired
    private HousingOrderMapper housingOrderMapper;
    @Autowired
    private HousingTrustMapper housingTrustMapper;

    /**
     * 查询交易管理
     * 
     * @param hoId 交易管理ID
     * @return 交易管理
     */
    @Override
    public HousingOrder selectHousingOrderById(Long hoId)
    {
        return housingOrderMapper.selectHousingOrderById(hoId);
    }

    /**
     * 查询交易管理列表
     * 
     * @param housingOrder 交易管理
     * @return 交易管理
     */
    @Override
    public List<HousingOrder> selectHousingOrderList(HousingOrder housingOrder)
    {
        List<HousingOrder> housingOrders = housingOrderMapper.selectHousingOrderList(housingOrder);
        for (int i = 0; i <housingOrders.size() ; i++) {
            housingOrders.get(i).setHousingTrust(housingTrustMapper.selectHousingTrustById(housingOrders.get(i).getHtId()));
        }
        return housingOrders;
    }

    /**
     * 新增交易管理
     * 
     * @param housingOrder 交易管理
     * @return 结果
     */
    @Override
    public int insertHousingOrder(HousingOrder housingOrder)
    {housingOrder.setCreateTime(DateUtils.getNowDate());
        return housingOrderMapper.insertHousingOrder(housingOrder);
    }

    /**
     * 修改交易管理
     * 
     * @param housingOrder 交易管理
     * @return 结果
     */
    @Override
    public int updateHousingOrder(HousingOrder housingOrder)
    {housingOrder.setUpdateTime(DateUtils.getNowDate());
        return housingOrderMapper.updateHousingOrder(housingOrder);
    }

    /**
     * 批量删除交易管理
     * 
     * @param hoIds 需要删除的交易管理ID
     * @return 结果
     */
    @Override
    public int deleteHousingOrderByIds(Long[] hoIds)
    {
        return housingOrderMapper.deleteHousingOrderByIds(hoIds);
    }

    /**
     * 删除交易管理信息
     * 
     * @param hoId 交易管理ID
     * @return 结果
     */
    @Override
    public int deleteHousingOrderById(Long hoId)
    {
        return housingOrderMapper.deleteHousingOrderById(hoId);
    }
}
